import {createRouter, createWebHashHistory, createWebHistory} from 'vue-router'

// import HomeView from '@/views/HomeView.vue'
// import SearchView from '@/views/SearchView.vue'
// import NotFind from '@/views/NotFind.vue'


const router = createRouter({
  // 配置路由模式: 默认是hash模式, 还有history模式
  // createWebHashHistory() -> hash模式 -> 路径中带#
  // createWebHistory() -> history模式 -> 路径中不带#
  history: createWebHashHistory(),
  routes: [
   // 路径重定向
   {path: '/', redirect: '/home'}, 
   {name: 'home', path: '/home', component: ()=>import('@/views/HomeView.vue')},
   // 动态路由传参  
   {name: 'search', path: '/search/:words?', component: ()=>import('@/views/SearchView.vue')},
   // 404页面放在路由规则数组的最后面
   {path: '/:catchAll(.*)', component: ()=>import('@/views/NotFind.vue')}
  ]
})

export default router